package br.iars.web.util;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class MessageResource {

	/**
	 * Name of resource
	 */
	private static final String RESOURCE_NAME = "messages";

	/**
	 * ResourceBundle to access the resource.
	 */
	private static ResourceBundle rb = ResourceBundle.getBundle(RESOURCE_NAME);

	/**
	 * Get the message represented by a key
	 * 
	 * @param key
	 *            The key of the message.
	 * @return The message.
	 */
	public static String get(String key, Object... parameters) {
		try {
			return MessageFormat.format(rb.getString(key), parameters);
		} catch (MissingResourceException e) {
			return key;
		}
	}
}
